<template>
    <view class="pd mt70">
    	<view class="formrow ">
    		<view class="z9 fz28">
    			备注
    		</view>
    		<view class="mt20 pr  ">
    			<input type="text" value="" class="jhhgerttyt" placeholder="请输入备注" v-model="form.remark"/>
    		</view>
    	</view>
		<view class="formrow mt70">
			<view class="z9 fz28">
				身份
			</view>
			<view class="mt20 pr  row">
				<view class="kjhsdrow row pt30 pm30  mr40" v-for="(sd,idx) in jhbnhxD" @tap="xsdfd(idx)">
					<view class="cz">
						<image src="../../../static/img/xuanhsd.png" class="kjjsee cz ab" v-if="jhghdf==idx"></image>
						<text class="kjjsee cz f_b" v-else></text>
					</view>
					<view class="col ml20 cf fz32 pt10">
						{{sd}}
					</view>
				
				</view>
			</view>
		</view>
		
		<view class="z9 fz26 mt70">
			该组织管理员权限授权
		</view>
		<view class="dsfsdttywer">
			<view class="mt20 pr parent">
				<view class="kjhnderty yj4 pr" :class="sd.cls" v-for="sd in sqssf" @tap="kjssf(sd)">
					<icon type="success" size="18" color="#fff" class="dsfrtyswr" />
					<view class="jjhdertt cen">
						<image :src="'../../../static/img/'+sd.icon" class="jhhdrettw cz" :class="sd.classname" mode="widthFix"></image>
					</view>
					<view class="cf fz26 cen">{{sd.name}}</view>
				</view>
			</view>
		</view>
		<view class="z9 fz26 mt70">
			该组织管理员权限授权
		</view>
		<view class="dsfsdttywer">
			<view class="mt20 pr parent">
				<view class="kjhnderty yj4 pr" :class="sd.cls" v-for="sd in sqssfb"  @tap="kjssf(sd)">
					<icon type="success" size="18" color="#fff" class="dsfrtyswr" />
					<view class="jjhdertt cen">
						<image :src="'../../../static/img/'+sd.icon" class="jhhdrettw cz" :class="sd.classname" mode="widthFix"></image>
					</view>
					<view class="cf fz26 cen">{{sd.name}}</view>
				</view>
			</view>
		</view>
		
    </view>
</template>
<script>
    export default {
        data() {
            return {
				form:{
					id:"",
					remark:'',
					identity:1,
					drive:'',
					dispatch:''
				},				
				jhghdf: 0,
				jhbnhxD: [
					'司机', '普通群员'
				],
				sqssf: [{
						icon: 'dfdsfa.png',
						classname: 'ba',
						name: '副钥匙分发',
						cls: '',
						id:"1"
					},
					{
						icon: 'dfdsfb.png',
						classname: 'bb',
						name: '副钥匙收回',
						cls: '',
						id:"2"
					}
				],
				sqssfb: [{
						icon: 'dfdsfc.png',
						classname: 'bc',
						name: '派车管理',
						cls: '',
						id:"1"
					},
					{
						icon: 'dfdsfd.png',
						classname: 'bb',
						name: '审批管理',
						cls: '',
						id:"2"
					}
				]
			}
        },
        components: {},
		onLoad(options) {			
			this.form.id=options.uid
		},
		onNavigationBarButtonTap() {
			this.edit()
		},
        methods: {
			xsdfd(idx) {
				this.jhghdf = idx				
				this.form.identity=idx + 1
			},
			kjssf(sd,index){
				if(sd.cls){
					sd.cls=''
				}else{
					sd.cls='act'
				}				
			},
			async edit(){				
				var power=this.sqssf,drives="",organize=this.sqssfb,dispatchs=""
				for(var val in power){							
					if(power[val].cls){
						drives+=power[val].id+","
					}							
				}
				if (drives.length > 0) {
				    drives = drives.substr(0, drives.length - 1);
				}
				for(var val in organize){
					if(organize[val].cls){
						dispatchs+=organize[val].id+","
					}							
				}
				if (dispatchs.length > 0) {
				    dispatchs = dispatchs.substr(0, dispatchs.length - 1);
				}
				console.log("0",dispatchs)
				this.form.drive=drives
				this.form.dispatch=dispatchs
				var bianji=await this.get("/api/group_user/modify",this.form,"PUT")
				console.log("编辑",bianji)
				uni.navigateBack({
					delta:1
				})
			}
		},
        mounted() {}
    }

</script>
<style  scoped>
	.jhhdrettw.ba,.jhhdrettw.bb{
		width: 66upx !important;
	}
	.jhhdrettw.bc{
		width: 56upx !important;
	}
</style>
